<template>
<diV >
<div class="dtheader" v-show="dtheadershow">
  <router-link to="/">
    <span class="iconfont header-link">&#xe6bc;</span>
  </router-link>
</div>
<div class="Ctylheader" v-show="!dtheadershow" :style="opacityStyle">
    查看详情
    <div>
      <router-link to="/">
        <span class="iconfont header-link">&#xe6bc;</span>
      </router-link>
    </div>
</div>
</div>
</template>

<script>
export default {
  name: 'DetailHeader',
  data () {
    return {
      dtheadershow: true,
      opacityStyle: {
        opacity: 0
      }
    }
  },
  methods: {
    handleScroll () {
      const top = document.body.scrollTop
      if (top > 25) {
        let opacity = top / 40
        opacity = opacity > 1 ? 1 : opacity
        this.opacityStyle = { opacity }
        this.dtheadershow = false
      } else {
        this.dtheadershow = true
      }
    }
  },
  mounted () {
    window.addEventListener('scroll', this.handleScroll)
  }
}
</script>

<style lang="stylus" scoped>
.dtheader
  position: absolute
  left: 0.4rem
  top: 0.4rem
  height: 2.4rem
  width: 2.4rem
  border-radius: 1.2rem
  overflow: hidden
  background: #000
  .iconfont
    color: #fff
    height: 2.4rem
    line-height: 2.4rem
    margin-left: .5rem
.Ctylheader
  height: 3rem
  background: #00bcd4
  line-height: 3rem
  color: #fff
  font-size: 1.2rem
  text-align: center
  position: fixed
  width: 100%
  left: 0
  top: 0
  z-index: 1000
  .header-link
    position: absolute
    left: 0
    top: 0
    color: #fff
    margin-left: .6rem
</style>
